<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Design Pattern</title>
    <meta name="language" content="en" />
    <!--myInjectedScript-->
</head>
<body>
    <h1>
        Bridge</h1>
    <div class="section">
        <h2>
            Intent</h2>
        <p>
            Decouple an abstraction from its implementation so that the two can vary independently.<br />
        </p>
    </div>
    <div class="section">
        <h2>
            Also known as</h2>
        <p>
            Handle/Body</p>
    </div>
    <div class="section">
        <h2>
            Motivation</h2>
        <p>
            When an abstraction can have one of several possible implementations, the usual
            way to accommodate them is to use inheritance. An abstract class defines the interface
            to the abstraction, and concrete subclasses implement it in different ways.<br />
But this approach isn't always flexible enough. <br />
Inheritance binds an implementation  to  the  abstraction  permanently,  which  makes  it  difficult  to  modify, extend, and reuse abstractions and implementations independently.
<br /><a href="http://en.wikipedia.org/wiki/bridge_pattern" target="_blank">Online resources</a>
               
        </p>
    </div>
    <div class="section">
        <h2>
            Applicability</h2>
        <p>
            <ol>
                <li>you want to avoid a permanent binding betweenan abstraction and its implementation.
                    This might be the case, for example, when the implementation must be selected or
                    switched at run-time.</li>
                <li>both the abstractions and their implementations should be extensible by subclassing.
                    In this case, the Bridge pattern lets you combine the different abstractions and
                    implementations and extend them independently.</li>
                <li>changes in the implementation of an abstraction should have no impact on clients,
                    hence their code should nothave to be recompiled. </li>
                <li>you want to share an implementation among multiple objects, and this fact should
                    be hidden from the client.</li>
            </ol>
        </p>
    </div>
    <div class="section">
        <h2>
            Class Diagram</h2>
        <p>
            <img alt="Diagram" src=" bridge.png" border="0" />
        </p>
    </div>
    <div class="section">
        <h2>
            Collaborations</h2>
        <p>
            Abstraction forwards client requests to its Implementor object.<br />
        </p>
    </div>
    <div class="section">
        <h2>
            Consequences</h2>
        <p>
            <ol>
                <li>Decoupling interface and implementation. An implementation is not bound permanently
                    to an interface. The implementation of an abstraction can be configured at run-time.
                    It's even possible for an object to change its implementation at run-time.<br />
                    Decoupling Abstraction and Implementor also eliminates compile-time dependencies
                    on the implementation.Changing an implementation class doesn't require recompiling
                    the Abstraction class and its clients. This property is essential when you must
                    ensure binary compatibility between different versions of a classlibrary.
                    <br />
                    Furthermore,this decoupling encourages layering that can lead to a better-structured
                    system. The high-level part of a system only has to know about Abstraction and Implementor.
                </li>
                <li>Improved extensibility. You can extend the Abstraction and Implementor hierarchies
                    independently. </li>
                <li>Hiding implementation details from clients. You can shield clients from implementation
                    details.</li>
            </ol>
        </p>
    </div>
    <div class="section">
        <h2>
            Related Patterns</h2>
        <p>
            <ul> 
                <li>An <a href="">Abstract Factory</a> can create and configure a particular <a href="">Bridge</a></li>
                <li>Sometimes can be replaced by <a href="">Adapter</a></li>
            </ul>
        </p>
    </div>
</body>
</html>
